home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / rdpix.pro < prev    next >
Encoding:
Text File  |  1997-07-08  |  2.3 KB  |  90 lines

  1. ; $Id: rdpix.pro,v 1.3 1997/01/15 03:11:50 ali Exp $
  2. ;
  3. ; Copyright (c) 1989-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. Pro Rdpix, Image,X0, Y0    ;Read the value of the pixel under the cursor
  7.             ;Display x,y and the pixel value under the cursor
  8. ;+
  9. ; NAME:
  10. ;    RDPIX
  11. ;
  12. ; PURPOSE:
  13. ;    Interactively display the X position, Y position, and pixel value 
  14. ;    of the cursor.
  15. ;
  16. ; CATEGORY:
  17. ;    Image display.
  18. ;
  19. ; CALLING SEQUENCE:
  20. ;    RDPIX, Image [, X0, Y0]
  21. ;
  22. ; INPUTS:
  23. ;    Image:    The array that represents the image being displayed.  This 
  24. ;        array may be of any type.  Rather reading pixel values from 
  25. ;        the display, they are taken from this parameter, avoiding 
  26. ;        scaling difficulties.
  27. ;
  28. ; OPTIONAL INPUT PARAMETERS:
  29. ;    X0, Y0:    The location of the lower-left corner of the image area on
  30. ;        screen.  If these parameters are not supplied, they are
  31. ;        assumed to be zero.
  32. ;
  33. ; OUTPUTS:
  34. ;    None.
  35. ;
  36. ; COMMON BLOCKS:
  37. ;    None.
  38. ;
  39. ; SIDE EFFECTS:
  40. ;    The X, Y, and value of the pixel under the cursor are continuously 
  41. ;    displayed.
  42. ;
  43. ; RESTRICTIONS:
  44. ;    None.
  45. ;
  46. ; PROCEDURE:
  47. ;    Instructions are printed and the pixel values are printed as the 
  48. ;    cursor is moved over the image.
  49. ;
  50. ;    Press the left or center mouse button to create a new line of output,
  51. ;    saving the previous line.
  52. ;
  53. ;    Press the right mouse button to exit the procedure.
  54. ;
  55. ; MODIFICATION HISTORY:
  56. ;    DMS, Dec, 1987.
  57. ;    Rob Montgomery (rob@hao.ucar.edu), 9/21/92;
  58. ;        Correct indices for case of !order = 1
  59. ;
  60. ;-
  61.  
  62. on_error,2              ;Return to caller if an error occurs
  63. print,'Press left or center mouse button for new output line."
  64. print,'... right mouse button to exit.'
  65. s = size(image)
  66. if s[0] ne 2 then message, 'Image parameter not 2d.'
  67. s[1] = s[1]-1        ;To n-1
  68. s[2] = s[2]-1
  69. !err=0
  70. if n_elements(x0) le 0 then x0 = 0
  71. if n_elements(y0) le 0 then y0 = 0
  72. if s[s[0]+1] ge 4 then form = 'F' else form = 'I'
  73. cr = string("15b)    ;this codes a newline
  74. form="($,'x=',i4,', y=',i4,', value=',"+form+",a)"
  75. while !err ne 4 do begin
  76.     CURSOR,x,y,2,/dev
  77.     if (!err and 3) ne 0 then begin    ;New line?
  78.        print,form="($,a)",string("12b)
  79.        while (!err ne 0) do begin wait,.1 & CURSOR,x,y,0,/dev & end
  80.       endif
  81.  
  82.     x = x-x0 & y = y - y0
  83.     if (x le s[1]) and (y le s[2]) and (x ge 0) and (y ge 0) then begin
  84.        if (!order eq 1) then yy = s[2] - y else yy = y
  85.        print,form = form, x,y,Image[x,yy],cr
  86.     endif
  87. endwhile
  88. print,form="(/)"
  89. end
  90.